package route

import (
	"cooke-home/task-service/di"
	"log"

	"github.com/gin-gonic/gin"
)

var Router *gin.Engine

func InitRouter() {
	log.Println("开始初始化路由...")
	Router = gin.Default()

	Router.GET("/health", func(c *gin.Context) {
		c.JSON(200, gin.H{
			"status": "ok",
		})
	})

	taskGroup := Router.Group("/task")
	{
		taskGroup.POST("/save", di.TaskController.Save)
		taskGroup.DELETE("/delete", di.TaskController.Delete)
		taskGroup.PUT("/update", di.TaskController.Update)
		taskGroup.GET("/get", di.TaskController.Get)
		taskGroup.GET("/list", di.TaskController.GetList)
		taskGroup.PUT("/update/complete/by/parentid", di.TaskController.UpdateCompleteByParentId)
		taskGroup.GET("/list/by/complete", di.TaskController.GetByComplete)
	}

	log.Println("路由初始化完成")
}
